//
//  NSNumber+YCTools.m
//  Pods
//
//  Created by Apple on 2024/9/26.
//

#import "NSNumber+YCTools.h"

@implementation NSNumber (YCTools)

+ (NSNumber *)ycNumberWithInt:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return[NSNumber numberWithInt:0];
    }
    return [NSNumber numberWithInt:[value intValue]];
}

+ (NSNumber *)ycNumberWithUnsignedInt:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return [NSNumber numberWithUnsignedInt:0];
    }
    return [NSNumber numberWithUnsignedInt:[value unsignedIntValue]];
}

+ (NSNumber *)ycNumberWithLong:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return [NSNumber numberWithLong:0];
    }
    return [NSNumber numberWithLong:[value longValue]];
}

+ (NSNumber *)ycNumberWithUnsignedLong:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return [NSNumber numberWithUnsignedLong:0];
    }
    return [NSNumber numberWithUnsignedLong:[value unsignedLongValue]];
}

+ (NSNumber *)ycNumberWithLongLong:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return [NSNumber numberWithLongLong:0];
    }
    return [NSNumber numberWithLongLong:[value longLongValue]];
}

+ (NSNumber *)ycNumberWithUnsignedLongLong:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return [NSNumber numberWithUnsignedLongLong:0];
    }
    return [NSNumber numberWithUnsignedLongLong:[value unsignedLongLongValue]];
}

+ (NSNumber *)ycNumberWithFloat:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return [NSNumber numberWithFloat:0.0];
    }
    return [NSNumber numberWithFloat:[value floatValue]];
}

+ (NSNumber *)ycNumberWithDouble:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return [NSNumber numberWithDouble:0.0];
    }
    return [NSNumber numberWithDouble:[value doubleValue]];
}

+ (NSNumber *)ycNumberWithBool:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return [NSNumber numberWithBool:NO];
    }
    return [NSNumber numberWithBool:[value boolValue]];
}

+ (NSNumber *)ycNumberWithInteger:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return [NSNumber numberWithInteger:0];
    }
    return [NSNumber numberWithInteger:[value integerValue]];
}

+ (NSNumber *)ycNumberWithUnsignedInteger:(id)value {
    if ([value isKindOfClass:[NSNull class]]) {
        return [NSNumber numberWithUnsignedInteger:0];
    }
    return [NSNumber numberWithUnsignedInteger:[value unsignedIntegerValue]];
}

@end
